package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 通过提高每次读写的数据量，减少实际读写次数，提高读写效率
 * 一组读写：块读写
 */
public class CopyDemo02 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("view.jpg");
        FileOutputStream fos=new FileOutputStream("view_copy02.jpg");
        long start=System.currentTimeMillis();
        byte[] by=new byte[1024*10];
        int len;
        while ((len=fis.read(by)) != -1) {
            fos.write(by,0,len);
        }
        long end=System.currentTimeMillis();
        System.out.println("finished, spent:"+(end-start)+" ms");
        fis.close();
        fos.close();
    }
}
